var createError = require('http-errors');
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
const cors = require('cors');

var indexRouter = require('./routes/index');

var app = express();
var http = require('http');
var server = http.createServer(app);
// view engine setup
// app.set('views', path.join(__dirname, 'views'));
// app.set('view engine', 'jade');

app.use(cors());
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

//Get请求
app.use('/', indexRouter);
//Post请求
app.use(bodyParser.urlencoded({extended:true}));


server.listen(3000);
console.log('服务器已启动，监听3000端口，请访问localhost:3000');
